<%@page import="model.bean.Canbo"%>
<%@page import="model.bean.Coquan"%>
<%@page import="model.bean.Chucvu"%>
<%@page import="java.util.ArrayList"%>
<%@page import="model.bean.Calendar"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String uName = (String) request.getSession().getAttribute("uName");
	String role = (String) request.getSession().getAttribute("role");	
	if((uName == null) || !("admin".equals(role) || !"user".endsWith(role))) {
		response.sendRedirect("login.jsp");
	}
%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>ĐỒ ÁN TỐT NGHIỆP</title>
<meta
	content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'
	name='viewport'>
<!-- bootstrap 3.0.2 -->
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<!-- font Awesome -->
<link href="css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<!-- Ionicons -->
<link href="css/ionicons.min.css" rel="stylesheet" type="text/css" />
<!-- Morris chart -->
<link href="css/morris/morris.css" rel="stylesheet" type="text/css" />
<!-- jvectormap -->
<link href="css/jvectormap/jquery-jvectormap-1.2.2.css" rel="stylesheet"
	type="text/css" />
<!-- Date Picker -->
<link href="css/datepicker/datepicker3.css" rel="stylesheet"
	type="text/css" />
<!-- Daterange picker -->
<link href="css/daterangepicker/daterangepicker-bs3.css"
	rel="stylesheet" type="text/css" />
<!-- bootstrap wysihtml5 - text editor -->
<link href="css/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css"
	rel="stylesheet" type="text/css" />
<!-- Theme style -->
<link href="css/AdminLTE.css" rel="stylesheet" type="text/css" />
<link href="mycss/popup.css" rel="stylesheet" type="text/css" />
</head>
<body class="skin-blue">

	<%
		ArrayList<Chucvu> dsChucvu = (ArrayList<Chucvu>)request.getAttribute("dsChucvu");
		    ArrayList<Coquan> dsCoquan = (ArrayList<Coquan>)request.getAttribute("dsCoquan");
		    Canbo cb = (Canbo)request.getAttribute("canbo");
		    String sua = (String)request.getAttribute("sua");
	%>
	<!-- header logo: style can be found in header.less -->
	<%@ include file="header.jsp"%>

	<div class="wrapper row-offcanvas row-offcanvas-left">
		<!-- Left side column. contains the logo and sidebar -->
		<%@ include file="menu.jsp"%>

		<!-- Right side column. Contains the navbar and content of the page -->
		<aside class="right-side"> <!-- Content Header (Page header) -->
		<section class="content-header">
		<h1>Quản lý cán bộ</h1>
		<ol class="breadcrumb">
			<li><a href="#"><i class="fa fa-dashboard"></i> Trang chủ</a></li>
			<li><a href="#">Quản lý cán bộ</a></li>
			<li class="active">Cập nhật</li>
		</ol>
		</section> <!-- Main content --> <section class="content">
		<div class="col-md-6">

			<%
				if ("true".equals(sua)) {
			%>
			<div class="alert alert-success alert-dismissable">
			<i class="fa fa-info"></i>
				<button type="button" class="close" data-dismiss="alert"
					aria-hidden="true">×</button>
				<b>Thông báo!</b> Cập nhật thông tin cán bộ thành công.
			</div>
			<%
				}
			%>

			<%
				if ("false".equals(sua)) {
			%>
			<div class="alert alert-danger alert-dismissable">
				<i class="fa fa-info"></i>
				<button type="button" class="close" data-dismiss="alert"
					aria-hidden="true">×</button>
				<b>Lỗi kết nối!</b> Cập nhật không thành công!
			</div>
			<%
				}
			%>
		</div>
		<div class="row">
			<!-- left column -->
			<div class="col-md-12">
				<!-- general form elements -->
				<div class="box box-primary">
					<!-- /.box-header -->
					<!-- form start -->
					<form action="CanBoServlet" method="post" name="mform">
						<div class="box-body">
							<div class="form-group">
								<%
									if(cb != null) {
								%>
								<div class="col-md-4">
									<input type="hidden" value="<%=cb.getIdCanbo()%>" name="idcb2"
										id="idcb2" /> <label>Chức vụ:</label>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-arrow-circle-down"></i>
										</div>
										<select class="form-control" name="idcv" id="idcv">
											<option value="<%=cb.getIdChucvu()%>"><%=cb.getTenChucvu()%></option>
											<%
												if(dsChucvu != null) {
																					for(Chucvu cv : dsChucvu) {
											%>
											<option value="<%=cv.getId()%>"><%=cv.getTencv()%></option>
											<%
												}
																				}
											%>
										</select>
									</div>
									<label>Phòng ban:</label>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-arrow-circle-down"></i>
										</div>
										<select class="form-control" name="idcq" id="idcq">
											<option value="<%=cb.getIdCoquan()%>"><%=cb.getTenCoquan()%></option>
											<%
												if(dsCoquan != null) {
																					for(Coquan cq : dsCoquan) {
											%>
											<option value="<%=cq.getIdcq()%>"><%=cq.getTencq()%></option>
											<%
												}
																				}
											%>
										</select>
									</div>
									<label>Ngày sinh:</label>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-clock-o"></i>
										</div>
										<input class="form-control" type="text" id="datepicker"
											value="<%=cb.getNgaySinh()%>" name="date" required="true">
									</div>
									</br> <label>Giới tính:</label>
									<%
										if("1".equals(cb.getGioiTinh())) {
									%>
									<input type="radio" name="sex" id="sex" checked="checked"
										value="1" required="true">Nam <input type="radio"
										name="sex" id="sex" value="0">Nữ
									<%
										} if("0".equals(cb.getGioiTinh())) {
									%>
									<input type="radio" checked="checked" name="sex" id="sex"
										value="1">Nam <input type="radio" checked="checked"
										name="sex" id="sex" value="0">Nữ
									<%
										}
									%>
								</div>
								<div class="col-md-8">
									<label>Tên cán bộ:</label>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-user"></i>
										</div>
										<input class="form-control" type="text"
											value="<%=cb.getTenCanbo()%>" name="tencb" id="tencb"
											required="true">
									</div>
									<label>Điện thoại:</label>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-phone"></i>
										</div>
										<input class="form-control" type="number"
											value="<%=cb.getSDT()%>" name="dienthoai" id="dienthoai"
											required="true">
									</div>
									<label>Email:</label>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-rss-square"></i>
										</div>
										<input class="form-control" type="email"
											value="<%=cb.getEmail()%>" name="email" id="email"
											required="true">
									</div>
									<label>Địa chỉ:</label>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa  fa-info-circle"></i>
										</div>
										<input class="form-control" type="text"
											value="<%=cb.getDiaChi()%>" name="diachicq" id="diachicq"
											required="true">
									</div>
									<%
										}
									%>
									<!-- /.form group -->
								</div>
								<!-- popup -->
								<div id="element_to_pop_up2">
									<a class="button b-close">X</a>
									<h4>Bạn chưa nhập đầy đủ dữ liệu!</h4>
									<a href="#" onclick="closepopup2()"><span
										class="button small pop1">OK</span></a>
								</div>
								<!-- Element to pop up -->
								<div id="element_to_pop_up">
									<a class="button b-close">X</a>
									<h4>Bạn có chắc chắn muốn cập nhật không?</h4>
									<a href="#" onclick="sua()"><span class="button small pop1">Đồng
											ý</span></a> <a href="#" onclick="closepopup()"><span
										class="button small pop1">Hủy</span></a>
								</div>
								</div>
								</div>
						</form>
					<div class="box-footer">
						<button class="btn btn-success" onclick="popup2()">Cập
							nhật</button>
						<a href="CanBoServlet?boqua" class="btn btn-primary">Bỏ qua</a>
					</div>
				</div>

			</div>
			<!-- /.box -->

			<!-- Form Element sizes -->

		</div>
		<!--/.col (left) -->
	</div>
	<!-- /.row -->
	</section>
	<!-- /.content -->
	</aside>
	<!-- /.right-side -->
	</div>
	<!-- ./wrapper -->
	<!-- jQuery 2.0.2 -->
	<script src="js/jquery.min.js"></script>
	<!-- Bootstrap -->
	<script src="js/bootstrap.min.js" type="text/javascript"></script>
	<!-- InputMask -->
	<script src="js/plugins/input-mask/jquery.inputmask.js"
		type="text/javascript"></script>
	<script src="js/plugins/input-mask/jquery.inputmask.date.extensions.js"
		type="text/javascript"></script>
	<script src="js/plugins/input-mask/jquery.inputmask.extensions.js"
		type="text/javascript"></script>
	<!-- date-range-picker -->
	<script src="js/plugins/daterangepicker/daterangepicker.js"
		type="text/javascript"></script>
	<!-- bootstrap color picker -->
	<script src="js/plugins/colorpicker/bootstrap-colorpicker.min.js"
		type="text/javascript"></script>
	<!-- bootstrap time picker -->
	<script src="js/plugins/timepicker/bootstrap-timepicker.min.js"
		type="text/javascript"></script>
	<!-- bootstrap datepicker -->
	<script src="js/plugins/datepicker/bootstrap-datepicker.js"
		type="text/javascript"></script>
	<!-- AdminLTE App -->
	<script src="js/AdminLTE/app.js" type="text/javascript"></script>
	<!-- AdminLTE for demo purposes -->
	<script src="js/AdminLTE/demo.js" type="text/javascript"></script>
	<!-- popup -->
	<script src="myjs/bpopup.min.js" type="text/javascript"></script>
	<!-- Page script -->
	<script>
		$(function() {
			$("#datepicker").datepicker({
				format : 'yyyy-dd-mm'
			});
		});

		function popup2() {
			var idcb2 = document.getElementById('idcb2').value;
			var idcq = document.getElementById('idcq').value;
			var idcv = document.getElementById('idcv').value;
			var datepicker = document.getElementById('datepicker').value;

			var tencb = document.getElementById('tencb').value;
			var sex = document.getElementById('sex').value;
			var dienthoai = document.getElementById('dienthoai').value;
			var email = document.getElementById('email').value;
			var diachicq = document.getElementById('diachicq').value;

			if (tencb == "" || dienthoai == "" || email == "" || diachicq == ""
					|| datepicker == "") {
				$('#element_to_pop_up2').bPopup({
					speed : 650,
					transition : 'slideIn',
					transitionClose : 'slideBack'
				});
			} else {
				$('#element_to_pop_up').bPopup({
					speed : 650,
					transition : 'slideIn',
					transitionClose : 'slideBack'
				});
			}
		}

		function sua() {
			document.forms["mform"].submit();
		}

		function closepopup() {
			$('#element_to_pop_up').bPopup().close();
		}
		function closepopup2() {
			$('#element_to_pop_up2').bPopup().close();

		}
	</script>
</body>
</html>